import 'package:honeypotflutter/net/public_http.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_modal.dart';
import '../model/signForModel.dart';

class SignForApi {
  /*
  * 获取签收设置列表
  * */
  static Future<List<SignForModel>> requestSignForList() async {
    try {
      var result = await MGHttp.get<List<dynamic>>("api/services/app/Account/GetMyAutoSignSetting");
      if (result == null) {
        return [];
      }
      var modelList = result.map((e) => SignForModel.fromJson(e)).toList();
      return modelList;
    } catch (error) {
      MGModal.totalError(error);
      return Future.error(error);
    }
  }

  /*
  * 设置签收列表
  * */
  static Future<bool> setSignFor(List list) async {
    try {
      Map param = {"settings": list};
      var result = await MGHttp.post(
        "api/services/app/Account/SetMyAutoSignSetting",
        progress: "提交中...",
        params: param,
      );
      return true;
    } catch (error) {
      MGModal.totalError(error);
      return Future.error(error);
    }
  }
}
